
<?php $__env->startSection('title', '新增角色'); ?>

<?php $__env->startSection('css'); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header"><h4>新增角色</h4></div>
                <div class="card-body">
                    <form action="<?php echo e(url('admin/role/add')); ?>" method="post">
                        <div class="form-group">
                            <label for="example-text-input"><span style="color:red;">*</span>&nbsp;角色名称</label>
                            <input class="form-control" type="text" name="name" placeholder="请输入角色名称" value="">
                        </div>
                        <div class="form-group">
                            <label for="example-text-input">角色描述</label>
                            <textarea class="form-control" id="remark" rows="5" name="remark" placeholder="请输入角色描述"></textarea>
                            <small class="help-block">角色描述，角色所属操作权限</small>
                        </div>
                        <div class="table-responsive">
                            <label for="example-text-input">角色权限</label>
                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th>
                                        <label class="lyear-checkbox checkbox-primary">
                                            <input name="checkbox" type="checkbox" id="check-all">
                                            <span> 全选</span>
                                        </label>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php if(count($menu_list) > 0): ?>
                                    <?php $__currentLoopData = $menu_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td>
                                            <label class="lyear-checkbox checkbox-primary">
                                                <input name="rules[]" type="checkbox" class="checkbox-parent" dataid="id-<?php echo e($v['id']); ?>" value="<?php echo e($v['id']); ?>">
                                                <span> <?php echo e($v['menu_name']); ?></span>
                                            </label>
                                        </td>
                                    </tr>
                                    <?php if(count($v['child']) > 0): ?>
                                        <?php $__currentLoopData = $v['child']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ck=>$cv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td class="p-l-30">
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input name="rules[]" type="checkbox" class="checkbox-parent checkbox-child" dataid="id-<?php echo e($v['id']); ?>-<?php echo e($cv['id']); ?>" value="<?php echo e($cv['id']); ?>">
                                                    <span> <?php echo e($cv['menu_name']); ?></span>
                                                </label>
                                            </td>
                                        </tr>
                                        <?php if(count($cv['child']) > 0): ?>
                                        <tr>
                                            <td class="p-l-60">
                                                <?php $__currentLoopData = $cv['child']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tk=>$tv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <label class="lyear-checkbox checkbox-primary checkbox-inline">
                                                    <input name="rules[]" type="checkbox" class="checkbox-child" dataid="id-<?php echo e($v['id']); ?>-<?php echo e($cv['id']); ?>-<?php echo e($tv['id']); ?>" value="<?php echo e($tv['id']); ?>">
                                                    <span> <?php echo e($tv['menu_name']); ?></span>
                                                </label>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </td>
                                        </tr>
                                        <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                        <div class="form-group">
                            <button class="btn btn-primary submitForm" type="button">保存</button>
                            <button class="btn btn-secondary" type="button" onclick="window.history.back(-1);">返回</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script type="text/javascript" src="<?php echo e(asset('static/js/chosen.jquery.min.js')); ?>"></script>
    <script type="text/javascript">
        $(function(){
            //动态选择框，上下级选中状态变化
            $('input.checkbox-parent').on('change', function(){
                var dataid = $(this).attr("dataid");
                $('input[dataid^=' + dataid + '-]').prop('checked', $(this).is(':checked'));
            });
            $('input.checkbox-child').on('change', function(){
                var dataid = $(this).attr("dataid");
                dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                var parent = $('input[dataid=' + dataid + ']');
                if($(this).is(':checked')){
                    parent.prop('checked', true);
                    //循环到顶级
                    while(dataid.lastIndexOf("-") != 2){
                        dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                        parent = $('input[dataid=' + dataid + ']');
                        parent.prop('checked', true);
                    }
                }else{
                    //父级
                    if($('input[dataid^=' + dataid + '-]:checked').length == 0){
                        parent.prop('checked', false);
                        //循环到顶级
                        while(dataid.lastIndexOf("-") != 2){
                            dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                            parent = $('input[dataid=' + dataid + ']');
                            if($('input[dataid^=' + dataid + '-]:checked').length == 0){
                                parent.prop('checked', false);
                            }
                        }
                    }
                }
            });
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.public.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\phpstudy_8.1\WWW\my_admin\resources\views/admin/role/add.blade.php ENDPATH**/ ?>